#include <iostream>
#include <string>
#include <vector>


size_t split(const std::string& str, const std::string& sep, std::vector<std::string>& result)
{
    int end = 0, start = 0;
    while(start < str.size()) //这里是start才对，start是一个新位置，待检测位置
    {
        end = str.find(sep, start);
        if(end == std::string::npos)
        {
            // if(end != start)
            // {
                // std::cout << end << " : " << start << std::endl;
                // std::cout << str.substr(start) << std::endl;
                result.push_back(str.substr(start));
            // }
            break;
        }
        if(end != start)
            result.push_back(str.substr(start, end - start));
        start = end + sep.size();
    }
    return result.size();

}
int main()
{
    std::string test_str = "...aaa...bbb..#..c.";
    std::cout << test_str.size() << std::endl;
    std::vector<std::string> result;
    split(test_str, ".", result);
    for(auto& str : result)
        std::cout << str << std::endl;
    return 0;
}